﻿<html>
  <head>
    <title></title>
    <div id="themefile"></div>    
    <style>
      @import 'this://app/images/public.css';
      @import 'this://app/images/form.css';
      html,body {overflow:scroll-indicator;margin:0;background:color(center-background-color);padding:0;width:100%;}
      .wrapper {height:*;padding:0 10dip;margin:0;}
      .titlebar {flow:horizontal-flow;width:*;display:block;}
      .titlebar_left {width:*;display:block;}
      .titlebar_right {width:*;text-align:right;display:block;}
      .content {display:block;clear:both;}
      label {display:block;}
      table {style-set:resizeable;border-collapse:collapse;border-spacing:0;width:*;margin-top:10dip;}
      table label {text-align:left;}
      table th {font-size:12dip;padding:0;border:1px solid color(manager-table-border-color);padding:5dip;width:*;text-align:left;font-weight:bold;}
      table td {font-size:12dip;padding:0;border:1px solid color(manager-table-border-color);padding:0 5dip;width:*;text-align:left;}
      table tr.checked {background:color(manager-tr-checked-background-color);}
      table tr:hover {background:color(manager-tr-hover-background-color);}
      table th:nth-child(1),table td:nth-child(1) {width:40dip;}
      table input[type='text'] {background:none;border:0;margin:0;text-align:left;display:block;}
      table input[type='checkbox'] {display:inline-block;}
      table input[type='text']:hover {background:none;}
      table .nosave {color:color(manager-input-nosave-text-color);}

      table tr.grp1 td{background-color:color(manager-grp1-tr-background-color);}
      table tr.grp2 td{background-color:color(manager-grp2-tr-background-color);}


      .openfile {cursor:pointer;}
      .pages {width:*;text-align:center;}
      .pages li {display:inline-block;size:20dip;line-height:20dip;border:1px solid color(manager-pages-border-color);background:color(manager-pages-background-color);text-align:center;color:color(manager-pages-text-color);margin:0 2dip;}
      .pages li:hover {background:color(manager-pages-hover-background-color);}
      .pages li:current {background:none;border:0;}
      select {width:100dip;}
      select option {display:block;}
      .tab_tip {background:color(manager-tip-background-color);color:color(manager-tip-text-color);line-height:20dip;height:20dip;font-size:12dip;display:block;padding:5dip;margin:-7dip 0 7dip 0;}

      /* 表格宽度 */
      #romlist_rombase th,#romlist_rombase td input{width:240dip}
      #romlist_rombase th:nth-child(3),#romlist_rombase td:nth-child(3) input{width:40dip}
      #romlist_rombase th:nth-child(4),#romlist_rombase td:nth-child(4) input{width:100dip}
      #romlist_rombase th:nth-child(5),#romlist_rombase td:nth-child(5) input{width:80dip}
      #romlist_rombase th:nth-child(6),#romlist_rombase td:nth-child(6) input{width:70dip}
      #romlist_rombase th:nth-child(8),#romlist_rombase td:nth-child(8) input{width:40dip}

      #rombase_submit{display:none}
      .form_bottom{border:0}

    </style>
  </head>
  <body>
    <tabs class="tabs" id="mytabs">
      <strip>
        <label ww="1200dip" wh="700dip" for="first" selected>{{RombaseManager}}</label>
        <label ww="1200dip" wh="700dip" for="second">{{MediaManager}}</label>
        <label ww="1200dip" wh="700dip" for="third">{{SimulatorManager}}</label>
        <label ww="800dip" wh="700dip" for="fourth">{{FileManager}}</label>
        <label ww="800dip" wh="700dip" for="fifth">{{RomRemoveDuplicate}}</label>
        <label ww="800dip" wh="700dip" for="sixth">{{InvalidResourceCleanup}}</label>
      </strip>
      <panels>
        <!-- 资料管理 -->
        <section id="first">
          <div class="tab_tip">{{TipEnterSave}}</div>
          <div class="wrapper">
            <div class="titlebar">
              <div class="titlebar_left">
                <select id="platform_rombase"></select>
                &nbsp;
                <select id="menu_rombase">
                  <option id="">{{SelectMenu}}</option>
                </select>
              </div>
              <div class="titlebar_right"></div>
            </div>
            <div class="content">
              <table id="romlist_rombase">
                <thead>
                  <tr>
                    <th>{{BaseRomName}}</th>
                    <th>{{BaseName}}</th>
                    <th>{{BaseYear}}</th>
                    <th>{{BaseType}}</th>
                    <th>{{BasePublisher}}</th>
                    <th>{{BaseCountry}}</th>
                    <th>{{BaseTranslate}}</th>
                    <th>{{BaseVersion}}</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
              <ul class="pages" id="pages_rombase"></ul>
              <div class="form_bottom">
                <button class="ok" id="rombase_submit">{{BatchUpdate}}</button>
          </div>
            </div>
          </div>
        </section>
        <!-- 媒体管理 -->
        <section id="second">
          <div class="tab_tip">{{TipInputPath}}</div>
          <div class="wrapper">
            <div class="titlebar">
              <div class="titlebar_left">
                <select id="platform_media"></select>
                &nbsp;
                <select id="menu_media">
                  <option>{{SelectMenu}}</option>
                </select>
              </div>
              <div class="titlebar_right"></div>
            </div>
            <div class="content">
              <table id="romlist_media">
                <thead>
                  <tr>
                    <th>{{BaseRomName}}</th>
                    <th>{{BaseName}}</th>
                    <th>{{Thumb}}</th>
                    <th>{{Snap}}</th>
                    <th>{{TitlePic}}</th>
                    <th>{{Poster}}</th>
                    <th>{{Packing}}</th>
                    <th>{{CassettePic}}</th>
                    <th>{{IconPic}}</th>
                    <th>{{GifPic}}</th>
                    <th>{{BackgroundPic}}</th>
                    <th>{{WallpaperPic}}</th>
                    <th>{{Video}}</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
              <ul class="pages" id="pages_media"></ul>
            </div>
          </div>
        </section>
        <!-- 模拟器管理 -->
        <section id="third">
          <div class="wrapper">
            <div class="titlebar">
              <div class="titlebar_left">
                <select id="platform_sim"></select>
                &nbsp;
                <select id="menu_sim">
                  <option id="">{{SelectMenu}}</option>
                </select>
              </div>
              <div class="titlebar_right">
                <select id="select_sim">
                  <option>{{SelectSimulator}}</option>
                </select>
                <select id="select_unzip">
                  <option value="">{{UnzipRun}}</option>
                  <option value="0">{{No}}</option>
                  <option value="1">{{Yes}}</option>
                </select>
                <button id="select_lua">{{SelectLua}}</button>
              </div>
            </div>
            <div class="content">
              <table id="romlist_sim" class="check_table">
                <thead>
                  <tr>
                    <th>{{Select}}<input type='checkbox' name='all_simulator' id='all_simulator' value='1' /></th>
                    <th>{{BaseRomName}}</th>
                    <th>{{BaseName}}</th>
                    <th>{{SimulatorName}}</th>
                    <th>{{BootParams}}</th>
                    <th>{{UnzipRun}}</th>
                    <th>{{RomCmdFile}}</th>
                    <th>{{Lua}}</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
              <ul class="pages" id="pages_sim"></ul>
            </div>
          </div>
        </section>
        <!-- 文件管理 -->
        <section id="fourth">
          <div class="wrapper">
            <div class="titlebar">
              <div class="titlebar_left">
                <select id="platform_file"></select>
                &nbsp;
                <select id="menu_file">
                  <option>{{SelectMenu}}</option>
                </select>
              </div>
              <div class="titlebar_right">
                <select id="select_hide">
                  <option value="">{{ShowHide}}</option>
                  <option value="1">{{Hide}}</option>
                  <option value="0">{{Show}}</option>
                </select>
                <button id="select_move">{{Move}}</button>
                <button id="select_delete">{{Delete}}</button>
              </div>
            </div>
            <div class="content">
              <table class="check_table" id="romlist_file">
                <thead>
                  <tr>
                    <th>{{Select}}<input type='checkbox' name='all_simulator' id='all_file' value='1' /></th>
                    <th>{{BaseRomName}}</th>
                    <th>{{BaseName}}</th>
                    <th>{{FilterMenu}}</th>
                    <th>{{Hide}}</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
              <ul class="pages" id="pages_file"></ul>
            </div>
          </div>
        </section>
        <!-- rom去重 -->
        <section id="fifth">
          <div class="tab_tip">
            {{TipRomRemoveDuplicate}}
          </div>
          <div class="wrapper">
            <div class="titlebar">
              <div class="titlebar_left">
                <select id="platform_repeat"></select>
              </div>
              <div class="titlebar_right">
                <button id="select_check_repeat">{{CheckDuplicate}}</button>
                <button id="select_move_repeat">{{Move}}</button>
                <button id="select_delete_repeat">{{Delete}}</button>
              </div>
            </div>
            <div class="content">
              <table class="check_table" id="romlist_repeat">
                <thead>
                  <tr>
                    <th>{{Select}}<input type='checkbox' name='all_simulator' id='all_repeat' value='1' /></th>
                    <th>{{BaseName}}</th>
                    <th>{{FilePath}}</th>
                    <th>{{FileSize}}</th>
                    <th>{{Function}}</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
            </div>
          </div>
        </section>
        <!-- 无效资源清理 -->
        <section id="sixth">
          <div class="tab_tip">{{TipClearZombie}}</div>
          <div class="wrapper">
            <div class="titlebar">
              <div class="titlebar_left">
                <select id="platform_zombie"></select>
              </div>
              <div class="titlebar_right">
                <button id="select_check_zombie">{{CheckZombie}}</button>
                <button id="select_move_zombie">{{Move}}</button>
                <button id="select_delete_zombie">{{Delete}}</button>
              </div>
            </div>
            <div class="content">
              <table class="check_table" id="romlist_zombie">
                <thead>
                  <tr>
                    <th>{{Select}}<input type='checkbox' name='all_simulator' id='all_zombie' value='1' /></th>
                    <th>{{BaseType}}</th>
                    <th>{{FilePath}}</th>
                  </tr>
                </thead>
                <tbody></tbody>
              </table>
            </div>
          </div>
        </section>
      </panels>
    </tabs>

    <script type="text/tiscript">
      include ROOTPATH + "tis/plugins/tabs.tis";
      include ROOTPATH + "tis/utils.tis";
      include ROOTPATH + "tis/dialog/rom_manager.tis";

      //初始化平台列表
      managerInit();

      /**
       * 通用
      **/

      //checkbox选中
      event click $(.check_table tbody input[type=checkbox]) {
        if(this.checked == true){
          this.checked = false;
          this.parent.parent.attributes.removeClass("checked");
        }else{
          this.checked = true;
          this.parent.parent.attributes.addClass("checked");
        }
      }

      //选择checkbox
      event click $(.check_table tbody tr){
        if (this.select("input[type=checkbox]").checked == true){
          this.select("input[type=checkbox]").checked = false;
          this.attributes.removeClass("checked");
        }else{
          this.select("input[type=checkbox]").checked = true;
          this.attributes.addClass("checked");
        }
      }

      //全选功能 - 模拟器管理
      event change $(#all_simulator){
        var checks = $$(.check_simulator);
        for(var c in checks){
            c.checked = this.checked;
            if(this.checked == true){
                c.parent.parent.attributes.addClass("checked");
            }else{
                c.parent.parent.attributes.removeClass("checked");
            }
        }
      }
      //全选功能 - 文件管理
      event change $(#all_file){
        var checks = $$(.check_file);
        for(var c in checks){
            c.checked = this.checked;
            if(this.checked == true){
                c.parent.parent.attributes.addClass("checked");
            }else{
                c.parent.parent.attributes.removeClass("checked");
            }
        }
      }
      //全选功能 - rom去重
      event change $(#all_repeat){
        var checks = $$(.check_repeat);
        for(var c in checks){
            c.checked = this.checked;
            if(this.checked == true){
                c.parent.parent.attributes.addClass("checked");
            }else{
                c.parent.parent.attributes.removeClass("checked");
            }
        }
      }
      //全选功能 - 无效资源清理
      event change $(#all_zombie){
        var checks = $$(.check_zombie);
        for(var c in checks){
            c.checked = this.checked;
            if(this.checked == true){
                c.parent.parent.attributes.addClass("checked");
            }else{
                c.parent.parent.attributes.removeClass("checked");
            }
        }
      }

      /**
       * 游戏资料管理
      **/

      //文本框修改 - 游戏资料管理
      event change $(table input[type=text]) {
        this.attributes.addClass("nosave");
      }

      //切换平台 - 游戏资料管理
      event change $(#platform_rombase){
        managerChangeRombasePlatform(this.value);
      }
      //切换目录 - 游戏资料管理
      event change $(#menu_rombase){
        managerChangeRombaseMenu(this.value);
      }

      //文本框保存修改 - 游戏资料管理
      event keydown $(#romlist_rombase input[type=text]) (evt,input) {
        if(evt.keyCode != Event.VK_RETURN){
          return ;
        }
        managerRombaseSave(this);
      }

      //批量更新 - 游戏资料管理
      
      event click $(#rombase_submit) {
        managerRombaseBatchSave();
      }
      

      //分页 - 游戏资料管理
      event click $(#pages_rombase li){
        managerCreateRombaseByPages(this);
      }

      /**
       * 媒体资源编辑
      **/


      //分页 - 媒体资源编辑
      event click $(#romlist_media .openfile){
       openFile(this);
       var type = this.select("input").attributes["class"];
       var id = this.parent.attributes["rid"];
       var path = this.select("input").value;
       mainView.EditRomThumbs(type,id,path);
      }


      //切换平台 - 媒体资源编辑
      event change $(#platform_media){
        managerChangeMediaPlatform(this.value);
      }

      //切换目录 - 媒体资源编辑
      event change $(#menu_media){
        managerChangeMediaMenu(this.value);
      }

      //分页 - 媒体资源编辑
      event click $(#pages_media li){
        managerCreateMediaByPages(this);
      }

      //编辑文本框 - 媒体资源编辑
      event keydown $(#romlist_media input[type=text]) (evt,input) {
        if(evt.keyCode != Event.VK_RETURN){
          return ;
        }
        managerSetMedia(this);
      }

      /**
       * 模拟器管理
      **/

      //切换平台 - 模拟器管理
      event change $(#platform_sim){
        managerChangeSimulatorPlatform(this.value);
      }

      //切换目录 - 模拟器管理
      event change $(#menu_sim){
        managerChangeSimulatorMenu(this.value);
      }

      //分页 - 模拟器管理
      event click $(#pages_sim li){
        managerCreateSimulatorByPages(this);
      }

      //编辑文本框资料 - 模拟器管理
      event keydown $(#romlist_sim input[type=text]) (evt,input) {
        if(evt.keyCode != Event.VK_RETURN){
          return ;
        }
        managerSimulatorSave(this);
      }

       //更改rom的模拟器 - 模拟器管理
       event change $(#select_sim){
          managerChangeRomSimulator(this);
       }

       //解压后运行 - 模拟器管理
       event change $(#select_unzip){
          managerChangeRomUnzipRunGame(this);
       }

       //选定lua脚本 - 模拟器管理
       event click $(#select_lua){
          openFileLua(this);
       }

      /**
       * 文件管理
      **/

      //切换平台 - 文件管理
      event change $(#platform_file){
        managerChangeRomFilePlatform(this.value);
      }
      //切换目录 - 文件管理
      event change $(#menu_file){
        managerChangeRomFileMenu(this.value);
      }

      //分页 - 文件管理
      event click $(#pages_file li){
        managerCreateRomFileByPages(this);
      }

      //隐藏 - 文件管理
       event change $(#select_hide){
        managerChangeRomHide(this.value);
      }

      //移动rom - 文件管理
      event click $(#select_move){
        managerFileMoveRom();
      }

      //删除rom - 文件管理
      event click $(#select_delete){
        managerFileDelete();
      }

      /**
       * rom去重
      **/


      //检测重复rom - rom去重
      event click $(#select_check_repeat){
        managerCheckRepeat();
      }
      //移动rom - rom去重
      event click $(#select_move_repeat){
        managerFileRepeatMoveRom();
      }

      //删除rom - rom去重
      event click $(#select_delete_repeat){
        managerFileRepeatDelete();
      }

      //运行游戏 - rom去重
      event click $(.rungame){
        managerRunGame(this);
      }

      /**
       * 无效资源清理
      **/


      //检测重复rom - 无效资源清理
      event click $(#select_check_zombie){
        managerCheckZombie();
      }
      //移动rom - 无效资源清理
      event click $(#select_move_zombie){
        managerFileZombieMoveRom();
      }

      //删除rom - 无效资源清理
      event click $(#select_delete_zombie){
        managerFileZombieDelete();
      }
      
    </script>
  </body>
</html>
